package com.example.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;

public class EnvConfig implements EnvironmentAware {
    private final Logger logger = LoggerFactory.getLogger(EnvConfig.class);

    private Environment env;

    public String getStringValue(String key){
        System.out.print("String-----:" + key);
        return env.getProperty(key);
    }

    public Long getLongValue(String key){
        String value = getStringValue(key);
        try{
            System.out.print("long-----:" + value);
            return Long.parseLong(value);
        }catch (Exception e){
            logger.error("#####transfer num err", e);
        }
        return 0L;
    }

    @Override
    public void setEnvironment(Environment environment) {
        this.env = environment;
    }
}
